<template>
	<view class="pa-b-100">
		<!--申请结佣-->
		<view class="bg-fff pa-20 pa-tb-30tn-text-xl">
			<view class=" font-bold ">醇香麦芽精酿啤酒‌500ml</view>
			<view class="flex f-center f-between ">
				<view>剩余积分数</view>
				<view class="tn-color-red">￥300.00</view>
			</view>
		</view>
		<view class="ma-20 pa-20 bg-fff b-r-15">
			<view class="flex f-center pa-b-20">
				<view class="w10vh">提现积分</view>
				<view class="ma-l-20 tn-text-sm"><tn-input type="number" v-model="amount" @input="cost"
						placeholder="请输入提现积分" />
				</view>
			</view>
			<view class="flex f-center pa-tb-20 b-t-1-F5">
				<view class="w10vh">积分价</view>
				<view class="flex f-center width70">
					<view class="ma-l-20 tn-text-sm width100"><tn-input v-model="actual_amount" disabled /></view>
					<text class="tn-icon-refresh icon_item--icon ma-l-10 c-fbbd12 tn-text-xxl"></text>
				</view>

			</view>
			<view class="flex f-center pa-tb-20 b-t-1-F5">
				<view class="w10vh">提现金额</view>
				<view class="ma-l-20 tn-text-sm"><tn-input v-model="management_fee" disabled placeholder="提现积分 x 积分价" />
				</view>
			</view>
		</view>
		<view class="ma-20 pa-20 bg-fff b-r-15">
			<view class="flex f-between">
				<view>收款账户</view>
				<view class="width60" v-if="receiving&&receiving.channel_type=='BANK_CARD'">
					<view>{{receiving.bank_account_name}}</view>
					<view class="pa-tb-10 c-aaa">{{receiving.bank_name}}</view>
					<view class=" c-aaa">银行卡号：{{receiving.bank_account_no}}</view>
				</view>
				<view class="width60" v-if="receiving&&receiving.channel_type=='WECHAT_PAY'">
					<view>{{receiving.wechat_pay_name}}</view>
					<view class="pa-tb-10 c-aaa">微信收款</view>
					<view class=" c-aaa">微信号：{{receiving.wechat_no}}</view>
				</view>
				<view class="width60" v-if="receiving&&receiving.channel_type=='ALIPAY'">
					<view>{{receiving.alipay_name}}</view>
					<view class="pa-tb-10 c-aaa">支付宝收款</view>
					<view class=" c-aaa">支付宝账号：{{receiving.alipay_no}}</view>
				</view>
				<view class="width60 tn-color-gray pa-b-100" v-else>您还未设置收款账户丨请点击右侧图标添加</view>
				<view @click="toPage('receiving')"
					class="tn-icon-bankcard icon_item--icon ma-l-10 c-fbbd12 tn-text-xxxl ma-r-20"></view>
			</view>
		</view>
		<view class="">
			<view class="flex">
				<view class="pa-t-10"><text class="tn-icon-tip icon_item--icon tn-text-xxl tn-padding-sm"></text></view>
				<view class="tn-text-md ma-r-30 lh50">
					<view class="font-bold tn-text-lg pa-tb-10">提现说明</view>
					<view class="c-aaa">
						<view>‌1、审核与打款时间‌：提交提现申请后，预计在7个工作日内完成审核并打款。</view>
						<view>‌2、提现规则‌：</view>
						<view class="ma-l-40">‌单次最小提现额度为100元；</view>
						<view class="ma-l-40">‌3天内仅限提现1次；</view>
						<view>3、税务责任‌：产生的劳务个税需自行年度汇算缴纳。若因未缴税导致风险，由申请人自行承担。</view>
						<view>‌4、账户信息‌：请务必准确填写收款账户信息。若因信息错误导致打款失败，请及时联系平台更正，打款时间将顺延处理。</view>
						<view>‌5、咨询方式‌：如有疑问，可拨打客服电话：400-8888-8888。</view>
					</view>
					‌
				</view>
			</view>
		</view>
		<!-- <view class="flex f-center ma-l-20">
			<tn-checkbox-group @change="checkboxGroupChange">
				<tn-checkbox v-model="checked" name="我已仔细研读并完全认同以上结佣条款">我已仔细研读并完全认同以上结佣条款</tn-checkbox>
			</tn-checkbox-group>
		</view> -->
		<view class="tn-flex-1 justify-content-item tn-margin-xs tn-text-center pa-t-30">
			<tn-button backgroundColor="#fbbd12" padding="40rpx 0" height="90rpx" width="90%" fontBold shape="round"
				@click="submit">
				<text class="tn-icon-plane-fill tn-padding-right-xs tn-color-white"></text>
				<text class="tn-color-white">提现</text>
			</tn-button>
		</view>

	</view>
</template>

<script>
	import appConfig from '@/config/config'
	import debounce from '@/util/debounce.js';
	var _this;
	export default {
		data() {
			return {
				amount: "",
				actual_amount: "1.1",
				management_fee: "",
				checked: false,
				commissionIntro: {},
				channel: {},
				channel_certs: [],
				receiving: {},
			}
		},
		mounted() {
			_this = this;
			// _this.getload();
			// _this.getChannel();
			// _this.getReceivingload();
		},
		methods: {
			//提现提交
			submit() {
				if (Number(_this.amount) < 100) {
					return _this.utilAlert.showInfo("请输入大于100整数", 2000);
				}
				var ivo = new Ivo("submitChannnelCommissionApplyAtMiniApp");
				ivo.set("apply_num", _this.amount); //提现金额
				_this.$EngineV2.action(ivo, ovo => {

				})
			},
			//计算提现管理费
			cost() {
				debounce(() => {
					var ivo = new Ivo("calculateWalletWithdrawalHandlingFeeAtMiniApp");
					if (Number(_this.amount) < 100) {
						return _this.utilAlert.showInfo("请输入大于100整数", 2000);
					}
					ivo.set("apply_num", _this.amount); //提现数量
					_this.$EngineV2.action(ivo, ovo => {
						console.log("计算提现管理费", ovo)
						_this.actual_amount = ovo.result.data.withdrawal_commission_handling_fee
							.withdrawal_commission;
						_this.management_fee = _this.amount - _this.actual_amount;
					})
				}, 800)
			},
			//获取银行卡信息
			getReceivingload() {
				var ivo = new Ivo("getChannelCommissionAccountAtMiniApp");
				_this.$EngineV2.action(ivo, ovo => {
					_this.receiving = ovo.result.data.wallet_withdrawal_channel;

				})
			},
			//获取提醒管理费说明
			getload() {
				var ivo = new Ivo("getChannelCommissionIntroAtMiniApp");
				_this.$EngineV2.action(ivo, ovo => {
					_this.commissionIntro = ovo.result.data.wallet_verification_desc;
					console.log("提醒说明", ovo)
				})
			},
			toPage(name, val) {
				if (name == "receiving") {
					_this.utilNav.navigateTo("/pages/my/editreceiving")
				}
			},
			checkboxGroupChange(e) {
				_this.checked = e.length > 0 ? true : false;
			},

		}
	}
</script>

<style lang="scss" scoped>
	.lh50 {
		line-height: 50rpx;
	}

	.w10vh {
		width: 15vh;
	}

	.delimg {
		position: absolute;
		top: 2px;
		right: 5%;
		width: 27px;
		height: 27px;
		border-radius: 50%;
		z-index: 20;
	}
</style>